package com.hp.test.java.thread.wait_notify.demo1;

public class Sample {
    private int number;

    public synchronized void increase() {
        while (0 != number) {
            try {
                wait();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

        number++;

        System.out.println(number);

        notify();
    }

    public synchronized void decrease() {
        while (0 == number) {
            try {
                wait();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

        number--;

        System.out.println(number);

        notify();
    }
}
